#include <stdint.h>

static const uint8_t gui_pal[8 * 3] =
{
    0x00, 0x00, 0x00, /* black      */
    0x3F, 0x3F, 0x3F, /* dark gray  */
    0x7F, 0x7F, 0x7F, /* gray       */
    0xBF, 0xBF, 0xBF, /* light gray */
    0xFF, 0xFF, 0xFF, /* white      */
    0xFF, 0x00, 0x00, /* red        */
    0x00, 0xFF, 0x00, /* green      */
    0x00, 0x00, 0xFF, /* blue       */
};

static const uint8_t nes_palettes[][192] = {
    {  // NES_PALETTE_NOFRENDO
        0x80, 0x80, 0x80, 0x10, 0x57, 0x9F, 0x43, 0x3A, 0xB0, 0x77, 0x22, 0xA6, 0x9F, 0x14, 0x83, 0xB0, 0x14, 0x51, 0xA6, 0x23, 0x1D, 0x83, 0x3D, 0x00,
        0x51, 0x59, 0x00, 0x1D, 0x72, 0x00, 0x00, 0x80, 0x10, 0x00, 0x7F, 0x43, 0x00, 0x70, 0x77, 0x00, 0x00, 0x00, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
        0xC0, 0xC0, 0xC0, 0x39, 0x80, 0xC8, 0x6C, 0x63, 0xD9, 0xA0, 0x4A, 0xCF, 0xC8, 0x3D, 0xAC, 0xD9, 0x3D, 0x7A, 0xCF, 0x4C, 0x46, 0xAC, 0x66, 0x1E,
        0x7A, 0x82, 0x0D, 0x46, 0x9B, 0x17, 0x1E, 0xA9, 0x39, 0x0D, 0xA8, 0x6C, 0x17, 0x99, 0xA0, 0x3D, 0x3D, 0x3D, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
        0xFF, 0xFF, 0xFF, 0x81, 0xC8, 0xFF, 0xB3, 0xAB, 0xFF, 0xE7, 0x92, 0xFF, 0xFF, 0x84, 0xF4, 0xFF, 0x85, 0xC2, 0xFF, 0x94, 0x8D, 0xF4, 0xAD, 0x65,
        0xC2, 0xCA, 0x54, 0x8D, 0xE3, 0x5E, 0x65, 0xF0, 0x81, 0x54, 0xF0, 0xB3, 0x5E, 0xE1, 0xE7, 0x78, 0x78, 0x78, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
        0xFF, 0xFF, 0xFF, 0xAD, 0xF3, 0xFF, 0xDF, 0xD6, 0xFF, 0xFF, 0xBE, 0xFF, 0xFF, 0xB0, 0xFF, 0xFF, 0xB1, 0xED, 0xFF, 0xBF, 0xB9, 0xFF, 0xD9, 0x91,
        0xED, 0xF6, 0x80, 0xB9, 0xFF, 0x8A, 0x91, 0xFF, 0xAD, 0x80, 0xFF, 0xDF, 0x8A, 0xFF, 0xFF, 0xC5, 0xC5, 0xC5, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
    },

    // FirebrandX palettes:

    { // NES_PALETTE_COMPOSITE
        0x65, 0x65, 0x65, 0x00, 0x12, 0x7D, 0x18, 0x00, 0x8E, 0x36, 0x00, 0x82, 0x56, 0x00, 0x5D, 0x5A, 0x00, 0x18, 0x4F, 0x05, 0x00, 0x38, 0x19, 0x00,
        0x1D, 0x31, 0x00, 0x00, 0x3D, 0x00, 0x00, 0x41, 0x00, 0x00, 0x3B, 0x17, 0x00, 0x2E, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xAF, 0xAF, 0xAF, 0x19, 0x4E, 0xC8, 0x47, 0x2F, 0xE3, 0x6B, 0x1F, 0xD7, 0x93, 0x1B, 0xAE, 0x9E, 0x1A, 0x5E, 0x99, 0x32, 0x00, 0x7B, 0x4B, 0x00,
        0x5B, 0x67, 0x00, 0x26, 0x7A, 0x00, 0x00, 0x82, 0x00, 0x00, 0x7A, 0x3E, 0x00, 0x6E, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0x64, 0xA9, 0xFF, 0x8E, 0x89, 0xFF, 0xB6, 0x76, 0xFF, 0xE0, 0x6F, 0xFF, 0xEF, 0x6C, 0xC4, 0xF0, 0x80, 0x6A, 0xD8, 0x98, 0x2C,
        0xB9, 0xB4, 0x0A, 0x83, 0xCB, 0x0C, 0x5B, 0xD6, 0x3F, 0x4A, 0xD1, 0x7E, 0x4D, 0xC7, 0xCB, 0x4C, 0x4C, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0xC7, 0xE5, 0xFF, 0xD9, 0xD9, 0xFF, 0xE9, 0xD1, 0xFF, 0xF9, 0xCE, 0xFF, 0xFF, 0xCC, 0xF1, 0xFF, 0xD4, 0xCB, 0xF8, 0xDF, 0xB1,
        0xED, 0xEA, 0xA4, 0xD6, 0xF4, 0xA4, 0xC5, 0xF8, 0xB8, 0xBE, 0xF6, 0xD3, 0xBF, 0xF1, 0xF1, 0xB9, 0xB9, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    },
    { // NES_PALETTE_NESCLASSIC
        0x61, 0x61, 0x61, 0x00, 0x00, 0x88, 0x1F, 0x0D, 0x99, 0x37, 0x13, 0x79, 0x56, 0x12, 0x60, 0x5D, 0x00, 0x10, 0x52, 0x0E, 0x00, 0x3A, 0x23, 0x08,
        0x21, 0x35, 0x0C, 0x0D, 0x41, 0x0E, 0x17, 0x44, 0x17, 0x00, 0x3A, 0x1F, 0x00, 0x2F, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xAA, 0xAA, 0xAA, 0x0D, 0x4D, 0xC4, 0x4B, 0x24, 0xDE, 0x69, 0x12, 0xCF, 0x90, 0x14, 0xAD, 0x9D, 0x1C, 0x48, 0x92, 0x34, 0x04, 0x73, 0x50, 0x05,
        0x5D, 0x69, 0x13, 0x16, 0x7A, 0x11, 0x13, 0x80, 0x08, 0x12, 0x76, 0x49, 0x1C, 0x66, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFC, 0xFC, 0xFC, 0x63, 0x9A, 0xFC, 0x8A, 0x7E, 0xFC, 0xB0, 0x6A, 0xFC, 0xDD, 0x6D, 0xF2, 0xE7, 0x71, 0xAB, 0xE3, 0x86, 0x58, 0xCC, 0x9E, 0x22,
        0xA8, 0xB1, 0x00, 0x72, 0xC1, 0x00, 0x5A, 0xCD, 0x4E, 0x34, 0xC2, 0x8E, 0x4F, 0xBE, 0xCE, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFC, 0xFC, 0xFC, 0xBE, 0xD4, 0xFC, 0xCA, 0xCA, 0xFC, 0xD9, 0xC4, 0xFC, 0xEC, 0xC1, 0xFC, 0xFA, 0xC3, 0xE7, 0xF7, 0xCE, 0xC3, 0xE2, 0xCD, 0xA7,
        0xDA, 0xDB, 0x9C, 0xC8, 0xE3, 0x9E, 0xBF, 0xE5, 0xB8, 0xB2, 0xEB, 0xC8, 0xB7, 0xE5, 0xEB, 0xAC, 0xAC, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    },
    { // NES_PALETTE_NTSC
        0x6A, 0x6D, 0x6A, 0x00, 0x13, 0x80, 0x1E, 0x00, 0x8A, 0x39, 0x00, 0x7A, 0x55, 0x00, 0x56, 0x5A, 0x00, 0x18, 0x4F, 0x10, 0x00, 0x38, 0x21, 0x00,
        0x21, 0x33, 0x00, 0x00, 0x3D, 0x00, 0x00, 0x40, 0x00, 0x00, 0x39, 0x24, 0x00, 0x2E, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xB9, 0xBC, 0xB9, 0x18, 0x50, 0xC7, 0x4B, 0x30, 0xE3, 0x73, 0x22, 0xD6, 0x95, 0x1F, 0xA9, 0x9D, 0x28, 0x5C, 0x96, 0x3C, 0x00, 0x7A, 0x51, 0x00,
        0x5B, 0x67, 0x00, 0x22, 0x77, 0x00, 0x02, 0x7E, 0x02, 0x00, 0x76, 0x45, 0x00, 0x6E, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0x68, 0xA6, 0xFF, 0x99, 0x92, 0xFF, 0xB0, 0x85, 0xFF, 0xD9, 0x75, 0xFD, 0xE3, 0x77, 0xB9, 0xE5, 0x8D, 0x68, 0xCF, 0xA2, 0x2C,
        0xB3, 0xAF, 0x0C, 0x7B, 0xC2, 0x11, 0x55, 0xCA, 0x47, 0x46, 0xCB, 0x81, 0x47, 0xC1, 0xC5, 0x4A, 0x4D, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0xCC, 0xEA, 0xFF, 0xDE, 0xDE, 0xFF, 0xEC, 0xDA, 0xFF, 0xF8, 0xD7, 0xFE, 0xFC, 0xD6, 0xF5, 0xFD, 0xDB, 0xCF, 0xF9, 0xE7, 0xB5,
        0xF1, 0xF0, 0xAA, 0xDA, 0xFA, 0xA9, 0xC9, 0xFF, 0xBC, 0xC3, 0xFB, 0xD7, 0xC4, 0xF6, 0xF6, 0xBE, 0xC1, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    },
    { // NES_PALETTE_PVM
        0x69, 0x6E, 0x69, 0x00, 0x17, 0x74, 0x1E, 0x00, 0x87, 0x34, 0x00, 0x73, 0x56, 0x00, 0x57, 0x5E, 0x00, 0x13, 0x53, 0x1A, 0x00, 0x3B, 0x24, 0x00,
        0x24, 0x30, 0x00, 0x06, 0x3A, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3B, 0x1E, 0x00, 0x30, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xB9, 0xBE, 0xB9, 0x14, 0x53, 0xB9, 0x4D, 0x2C, 0xDA, 0x67, 0x1E, 0xDE, 0x98, 0x18, 0x9C, 0x9D, 0x23, 0x44, 0xA0, 0x3E, 0x00, 0x8D, 0x55, 0x00,
        0x65, 0x6D, 0x00, 0x2C, 0x79, 0x00, 0x00, 0x81, 0x00, 0x00, 0x7D, 0x42, 0x00, 0x78, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0x69, 0xA8, 0xFF, 0x96, 0x91, 0xFF, 0xB2, 0x8A, 0xFA, 0xEA, 0x7D, 0xFA, 0xF3, 0x7B, 0xC7, 0xF1, 0x8F, 0x6C, 0xE6, 0xAD, 0x27,
        0xD7, 0xC8, 0x05, 0x90, 0xDF, 0x07, 0x64, 0xE5, 0x3C, 0x45, 0xE2, 0x7D, 0x48, 0xD5, 0xD9, 0x4B, 0x50, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0xD2, 0xEA, 0xFF, 0xE2, 0xE2, 0xFF, 0xE9, 0xD8, 0xFF, 0xF5, 0xD2, 0xFF, 0xF8, 0xD9, 0xEA, 0xFA, 0xDE, 0xB9, 0xF9, 0xE8, 0x9B,
        0xF3, 0xF2, 0x8C, 0xD3, 0xFA, 0x91, 0xB8, 0xFC, 0xA8, 0xAE, 0xFA, 0xCA, 0xCA, 0xF3, 0xF3, 0xBE, 0xC3, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    },
    { // NES_PALETTE_SMOOTH
        0x6A, 0x6D, 0x6A, 0x00, 0x13, 0x80, 0x1E, 0x00, 0x8A, 0x39, 0x00, 0x7A, 0x55, 0x00, 0x56, 0x5A, 0x00, 0x18, 0x4F, 0x10, 0x00, 0x3D, 0x1C, 0x00,
        0x25, 0x32, 0x00, 0x00, 0x3D, 0x00, 0x00, 0x40, 0x00, 0x00, 0x39, 0x24, 0x00, 0x2E, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xB9, 0xBC, 0xB9, 0x18, 0x50, 0xC7, 0x4B, 0x30, 0xE3, 0x73, 0x22, 0xD6, 0x95, 0x1F, 0xA9, 0x9D, 0x28, 0x5C, 0x98, 0x37, 0x00, 0x7F, 0x4C, 0x00,
        0x5E, 0x64, 0x00, 0x22, 0x77, 0x00, 0x02, 0x7E, 0x02, 0x00, 0x76, 0x45, 0x00, 0x6E, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0x68, 0xA6, 0xFF, 0x8C, 0x9C, 0xFF, 0xB5, 0x86, 0xFF, 0xD9, 0x75, 0xFD, 0xE3, 0x77, 0xB9, 0xE5, 0x8D, 0x68, 0xD4, 0x9D, 0x29,
        0xB3, 0xAF, 0x0C, 0x7B, 0xC2, 0x11, 0x55, 0xCA, 0x47, 0x46, 0xCB, 0x81, 0x47, 0xC1, 0xC5, 0x4A, 0x4D, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0xFF, 0xFF, 0xFF, 0xCC, 0xEA, 0xFF, 0xDD, 0xDE, 0xFF, 0xEC, 0xDA, 0xFF, 0xF8, 0xD7, 0xFE, 0xFC, 0xD6, 0xF5, 0xFD, 0xDB, 0xCF, 0xF9, 0xE7, 0xB5,
        0xF1, 0xF0, 0xAA, 0xDA, 0xFA, 0xA9, 0xC9, 0xFF, 0xBC, 0xC3, 0xFB, 0xD7, 0xC4, 0xF6, 0xF6, 0xBE, 0xC1, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    },
};
